#include<bits/stdc++.h>
using namespace std;
int main(){
  freopen("bishop.in","r",stdin);
  freopen("bishop.out","w",stdout);
  ios::sync_with_stdio(false);
  int h,w; bool f=false; cin>>h>>w;
  if(h>w)f=true,swap(h,w);
  vector<pair<int,int> > r;
  set<int> p,m;
  auto I=[&](int x,int y){
    if(p.find(x+y)==p.end()&&m.find(x-y)==m.end())
      p.emplace(x+y),m.emplace(x-y),r.emplace_back(x,y);
  };
  for(int i=0;i<h;i++)I(i,0);
  for(int i=0;i<h;i++)I(i,w-1);
  for(int i=0;i<w;i++)I(h-1>>1,i),I(h>>1,i);
  cout<<r.size()<<endl;
  if(f)for(auto &[x,y]:r)swap(x,y);
  for(auto [x,y]:r)cout<<x+1<<' '<<y+1<<'\n';
  return 0;
}